package com.zyg.dao.impl;

import com.zyg.dao.AccountDao;
import org.springframework.jdbc.core.JdbcTemplate;

public class AccountDaoImpl implements AccountDao{

	private JdbcTemplate jdbcTemplate;

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	public void transfer(String outUser,String inUser,Double money){

		System.out.println("transfer....");
		jdbcTemplate.update("update account set balance=balance-? where username=?", money, outUser);
		//int a = 1/0;
		jdbcTemplate.update("update account set balance=balance+? where username=?",money,inUser);
		System.out.println( "转账成功！" );
	}
}
